package com.wh.book2.mapper;

import com.wh.book2.model.BookInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BookMapper {
    @Select("select * from book_info where status != 0 and id = #{id}")
    public BookInfo getBookById(Integer id);

    @Insert("insert into book_info (book_name, author, count, price, publish, `status`) " +
            "values (#{bookName}, #{author}, #{count}, #{price}, #{publish}, #{status})")
    public Integer insertBook(BookInfo bookInfo);

    @Select("select * from book_info where status != 0 limit #{offSet},#{limit}")
    public List<BookInfo> getBookListByPage(Integer offSet, Integer limit);

    @Select("select count(1) from book_info where status != 0")
    public Integer getCount();

    public Integer updateBookById(BookInfo bookInfo);

    int batchDelete(List<Integer> ids);
}
